package com.xyz.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author zsr
 * @date 2021/6/23 22:24
 */
@Component
@PropertySource(value = {"classpath:dev-key.yml"},factory = YamlAndPropertySourceFactory.class)
public class ConstantPropertiesUtils implements InitializingBean {

    @Value("${spring.mail.username}")
    private String mailUsername;
    @Value("${weixin.pay.appid}")
    private String appid;

    @Value("${weixin.pay.partner}")
    private String partner;

    @Value("${weixin.pay.partnerkey}")
    private String partnerkey;

    @Value("${weixin.pay.notifyurl}")
    private String notifyurl;
    //oss服务器地址
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;

    //accessKey
    @Value("${aliyun.oss.file.keyid}")
    private String keyId;

    //accessKey
    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;

    //文件夹名
    @Value("${aliyun.oss.file.filehost}")
    private String fileHost;

    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;

    public static String PAY_APPID;
    public static String PAY_PARTNER;
    public static String PAY_PARTNERKEY;
    public static String PAY_NOTIFYURL;

    public static String MAIL_USERNAME;

    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    public static String FILE_HOST ;

    @Override
    public void afterPropertiesSet() throws Exception {
        PAY_APPID=this.appid;
        PAY_PARTNER=this.partner;
        PAY_PARTNERKEY=this.partnerkey;
        PAY_NOTIFYURL=this.notifyurl;
        MAIL_USERNAME=this.mailUsername;
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
        FILE_HOST = fileHost;
    }
}
